﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//
using System.IO;
/*
Copyright 2010 Mirosław M. Mączka

This file is part of Flac2Wma.

    Flac2Wma is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
namespace Flac2Wma
{
    public class Log
    {
        private string t = "";
        //
        public Log()
        {
            t = "";
        }
        //
        public string AddTitle(string title)
        {
        //    t = t + Environment.NewLine + title;
        //    return title;
            //t = "";
            return AddEntry(0, Log.CleanFormatString(title));
        }
        //public string AddEntry(string entry)
        //{
        //    t = t + Environment.NewLine + "  " + entry;
        //    return entry;
        //}
        public string AddEntry(int level, string fmt, params object [] pp)
        {
            fmt = Log.CleanFormatString(fmt);
            string entry = string.Format(fmt, pp);
            t += Environment.NewLine + "".PadRight(level*2, ' ') + entry;
            return entry;
        }
        public string Get()
        {
            return t + Environment.NewLine;
        }
        public bool Save(string path)
        {
            //
            return Utils.WriteString(Path.Combine(path, @"___Flac2Wma.log"), t);
        }
        static public string CleanFormatString(string fmt)
        {
            return fmt.Replace('{', '(').Replace('}',')');
        }
    }//class
}//namespace
